package com.southwind.springboottest.studykotlin.s2;
interface IShowResult{
    void result(String result);
}
/**
 * @description：TODO 34.Kotlin语言的匿名函数与县名函数
 */
public class KtBase34 {
    public static void main(String[] args) {
        //匿名函数 - 匿名接口实现
        showPersonInfo("lisi", 99, '男', "study cpp", new IShowResult() {
            @Override
            public void result(String result) {
                System.out.println("显示结果：" + result);
            }
        });
        //具名函数 showResultImpl
        IShowResult showResult = new MshowResultImpl();
        showPersonInfo("wangwu",88,'女',"study kt",showResult);
    }
    static class MshowResultImpl implements IShowResult{

        @Override
        public void result(String result) {
            System.out.println("显示结果：" + result);
        }
    }
    static void showPersonInfo(String name,int age,char sex,String study,IShowResult iShowResult){
        String str = String.format("name:%s,age:%d,sex:%c,study:%s",name,age,sex,study);
        iShowResult.result(str);
    }
}
